﻿using System;
using System.Collections.Generic;
using NUnit.Framework;
using Lottery.App.DAL;
using Lottery.App.Model;
using Lottery.App.Utility;

namespace Lottery.App.Test
{
    public class Helper
    {
        public void InitA1()
        {
            List<string> list = Utils.Get20P1();

            A1Dao dao = new A1Dao();

            dao.BeginTransaction();

            foreach (string item in list)
            {
                dao.Save(new A1Info() { Value = item });
            }

            dao.CommitTransaction();
        }

        public void InitA2()
        {
            List<string> list = Utils.Get20A2();

            A2Dao dao = new A2Dao();

            dao.BeginTransaction();

            foreach (string item in list)
            {
                dao.Save(new A2Info() { Value = item });
            }

            dao.CommitTransaction();
        }

        public void InitA3()
        {
            List<string> list = Utils.Get20A3();

            A3Dao dao = new A3Dao();

            dao.BeginTransaction();

            foreach (string item in list)
            {
                dao.Save(new A3Info() { Value = item });
            }

            dao.CommitTransaction();
        }

        public void InitP2()
        {
            List<string> list = Utils.Get20P2();

            P2Dao dao = new P2Dao();

            dao.BeginTransaction();

            foreach (string item in list)
            {
                dao.Save(new P2Info() { Value = item });
            }

            dao.CommitTransaction();
        }

        public void InitP3()
        {
            List<string> list = Utils.Get20P3();

            P3Dao dao = new P3Dao();

            dao.BeginTransaction();

            foreach (string item in list)
            {
                dao.Save(new P3Info() { Value = item });
            }

            dao.CommitTransaction();
        }

        public void InitN2()
        {
            List<string> list = Utils.Get20P2();

            N2Dao dao = new N2Dao();

            dao.BeginTransaction();

            foreach (string item in list)
            {
                dao.Save(new N2Info() { Value = item });
            }

            dao.CommitTransaction();
        }

        public void InitN3()
        {
            List<string> list = Utils.Get20P3();

            N3Dao dao = new N3Dao();

            dao.BeginTransaction();

            foreach (string item in list)
            {
                dao.Save(new N3Info() { Value = item });
            }

            dao.CommitTransaction();
        }

        public void InitN4()
        {
            List<string> list = Utils.Get20P4();

            N4Dao dao = new N4Dao();

            dao.BeginTransaction();

            foreach (string item in list)
            {
                dao.Save(new N4Info() { Value = item });
            }

            dao.CommitTransaction();
        }

        public void InitN5()
        {
            List<string> list = Utils.Get20P5();

            N5Dao dao = new N5Dao();

            dao.BeginTransaction();

            foreach (string item in list)
            {
                dao.Save(new N5Info() { Value = item });
            }

            dao.CommitTransaction();
        }

        public void InitB4Z3()
        {
            List<string> list = Utils.Get20P4();

            B4Z3Dao dao = new B4Z3Dao();

            dao.BeginTransaction();

            foreach (string item in list)
            {
                dao.Save(new B4Z3Info() { Value = item });
            }

            dao.CommitTransaction();
        }

        public void InitB5Z4()
        {
            List<string> list = Utils.Get20P5();

            B5Z4Dao dao = new B5Z4Dao();

            dao.BeginTransaction();

            foreach (string item in list)
            {
                dao.Save(new B5Z4Info() { Value = item });
            }

            dao.CommitTransaction();
        }

        public void InitB6Z5()
        {
            List<string> list = Utils.Get20P6();

            B6Z5Dao dao = new B6Z5Dao();

            dao.BeginTransaction();

            foreach (string item in list)
            {
                dao.Save(new B6Z5Info() { Value = item });
            }

            dao.CommitTransaction();
        }

        public void InitD1T2()
        {
            List<string> list = Utils.GetD1T2();

            D1T2Dao dao = new D1T2Dao();

            dao.BeginTransaction();

            foreach (string item in list)
            {
                
                dao.Save(new D1T2Info()
                {
                    Value = item,
                    DM = item.Substring(0, 2),
                    TM = item.Substring(3)
                });
            }

            dao.CommitTransaction();
        }

    }
}
